package cn.hl.sfzy.controller;


import cn.hl.sfzy.entity.ConsultReply;
import cn.hl.sfzy.service.ConsultReplyService;
import cn.hl.sfzy.util.Result;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @ClassName ConsultReplyController
 * @Description TODO
 * @Author LiuYao
 * @Date 2024年10月26日 11:00
 * @Version 1.0
 */
@RestController
@RequestMapping("/consultReply")
public class ConsultReplyController {
    @Autowired
    private ConsultReplyService consultReplyService;

    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable Long id) {
        consultReplyService.delete(id);
        return Result.success("删除成功");
    }
    @PostMapping("/insert")
    public Result insert(@RequestBody ConsultReply consultReply) {
        consultReplyService.add(consultReply);
        return Result.success("添加成功！");
    }
    @PutMapping("/update")
    public Result update(@RequestBody ConsultReply consultReply) {
        consultReplyService.update(consultReply);
        return Result.success(consultReply);
    }
    @GetMapping("/findByPage")
    public Result findByPage(@RequestParam(required = false,defaultValue = "1") int pageNum, @RequestParam(required = false,defaultValue = "5") int pageSize, ConsultReply consultReply) {
        PageInfo<ConsultReply> info = consultReplyService.findByPage(pageNum, pageSize, consultReply);
        return Result.success(info);
    }
}
